package com.buptse.utils;

import com.buptse.model.Information;

//灾情指标解码
public class IndexDecoder {
    enum IndexCategory{
        _1001("1001","地理位置"),
        _1002("1002","时间"),
        _1003("1003","震级"),
        _1004("1004","震源深度"),
        _1005("1005","烈度"),
        _2001("2001","受灾人数"),
        _2002("2002","受灾程度"),
        _3001("3001","一般损坏面积"),
        _3002("3002","严重损坏面积"),
        _3003("3003","受灾程度"),
        _4001("4001","受灾设施数"),
        _4002("4002","受灾范围"),
        _4003("4003","受灾程度"),
        _5001("5001","灾害损失"),
        _5002("5002","灾害范围"),
        _5003("5003","灾害程度");


        private String code;
        private String description;

        // 枚举的构造函数，可以带不同的参数
        IndexCategory(String code, String description) {
            this.code = code;
            this.description=description;
        }

        public String getCode() {
            return code;
        }


        public String getDescription() {
            return description;
        }

        public static String getInfoByCode(String code) {
            for (IndexCategory indexCategory : values()) {
                if (indexCategory.getCode().equals(code)) {
                    return indexCategory.getDescription();
                }
            }
            return "Code not found";
        }
    }

    public static void indexDecode(String code, Information information){
        String indexInformation=IndexCategory.getInfoByCode(code);
        information.setIndexing(indexInformation);
    }
}
